library(sf)
library(tidyverse)
library(leaflet)
parks_shp<-st_read("../data/Open_Space_Parks/geo_export_c3910f09-62a7-48c3-b859-47e26ec50538.shp")
## Reading layer `geo_export_c3910f09-62a7-48c3-b859-47e26ec50538' from data source `/Users/kristenakey/Desktop/Fall2020-Project2-group2/data/Open_Space_Parks/geo_export_c3910f09-62a7-48c3-b859-47e26ec50538.shp' using driver `ESRI Shapefile'
## Simple feature collection with 12491 features and 10 fields
## geometry type: POLYGON
## dimension: XY
## bbox: xmin: -74.25537 ymin: 40.49613 xmax: -73.70182 ymax: 40.91138
## geographic CRS: WGS84(DD)
parks_shp %>%
filter(!is.na(landuse),
(landuse %in% c("Waterfront Facility",'Lot', 'Buildings/Institutions', 'Tracking Only',
'<Null>', 'Undeveloped', 'Cemetery', 'Retired N/A', 'Tracking')) == FALSE) %>%
mutate(landuse = case_when(landuse=="Community Park" ~ "Park",
landuse=="Neighborhood Park" ~ "Park",
landuse=="Historic House Park" ~ "Park",
landuse=="Triangle/Plaza" ~ "Triangle/Plaza",
landuse=="Recreation Field/Courts" ~ "Recreation Field/Courts",
landuse=="Playground" ~ "Playground",
landuse=="Nature Area" ~ "Nature Area",
landuse=="Parkway" ~ "Parkway",
landuse=="LARGE PARK AREA" ~ "Park",
landuse=="Flagship Park" ~ "Park",
landuse=="EventArea" ~ "Park",
landuse=="Mall" ~ "Parkway",
landuse=="Garden" ~ "Parkway",
landuse=="Jointly Operated Playground" ~ "Playground",
landuse=="School Yard to Playground" ~ "Playground",
landuse=="Strip" ~ "Parkway"
)
) -> parks_shp
parks_shp %>%
as.tibble() %>%
dplyr::select(landuse) %>% distinct()
## # A tibble: 6 x 1
## landuse
## <chr>
## 1 Park
## 2 Triangle/Plaza
## 3 Parkway
## 4 Recreation Field/Courts
## 5 Playground
## 6 Nature Area
## save cleaned shapefile
# st_write(parks_shp, "../data/nyc_parks.shp")
Plot of parks
labels <- sprintf(
"<strong>%s</strong>",
parks_shp$park_name
) %>% lapply(htmltools::HTML)
leaflet() %>% addTiles() %>%
setView(lng = -73.98928, lat = 40.75042,zoom=11) %>%
addPolygons(data=parks_shp,weight=5,col = 'green',
label = labels,
labelOptions = labelOptions(
style = list("font-weight" = "normal", padding = "3px 8px"),
textsize = "15px",
direction = "auto")) %>%
addProviderTiles("CartoDB.Positron", options = providerTileOptions(noWrap = TRUE))